package cc.wsyw126.java.nowcoder;

import java.util.Scanner;

/**
 * Created by Administrator on 2017/4/12.
 */
public class AssembleTriangle {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            int n = Integer.parseInt(s);
            int count = 0;
            if (n<3) {
                System.out.println(count);
                return;
            }
            String s1 = scanner.nextLine();
            String[] split = s1.split(" ");
            for (int i = 0; i < split.length - 2; i++) {
                for (int j = i + 1; j < split.length - 1; j++) {
                    for (int k = j + 1; k < split.length; k++) {
                        count += checkTriangle(Integer.parseInt(split[i]), Integer.parseInt(split[j]), Integer.parseInt(split[k]));
                    }
                }
            }
            System.out.println(count);
        }
    }

    private static int checkTriangle(Integer a, Integer b, Integer c) {
        return a < b + c && b < a + c && c < a + b ? 1 : 0;
    }
}
